/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.pay.component;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import com.qihoo.gamecenter.sdk.common.i.s;
import com.qihoo.gamecenter.sdk.pay.res.b;
import com.qihoo.stat.QHStatDo;

public abstract class a {
    private boolean f;
    private boolean g;
    private boolean h;
    private int i;
    private View j;
    private ImageView k;
    private c l;
    private ImageView m;
    private FrameLayout n;
    private LinearLayout o;
    protected int a;
    protected Intent b;
    protected Activity c;
    protected b d;
    protected com.qihoo.gamecenter.sdk.pay.k.a e;
    private boolean p = true;
    private DialogInterface.OnCancelListener q = new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface paramDialogInterface) {
            if (a.this.e == null)
                return;
            a.this.e.a(a.a(a.this), a.b(a.this), new Object[0]);
        }
    };
    private DialogInterface.OnDismissListener r = new DialogInterface.OnDismissListener() {
        public void onDismiss(DialogInterface paramDialogInterface) {
            if ((a.c(a.this)) && (a.this.e != null))
                a.this.e.a(a.a(a.this), a.b(a.this), new Object[] { Boolean.valueOf(a.d(a.this)) });
            a.a(a.this, true);
        }
    };

    public a(Activity paramActivity, Intent paramIntent) {
        this.d = b.a(paramActivity);
        this.b = paramIntent;
        this.c = paramActivity;
        this.i = 65285;
        this.f = false;
        this.g = false;
        this.h = false;
    }

    public void a(int paramInt) {
        this.n = new FrameLayout(this.c);
        FrameLayout localFrameLayout = new FrameLayout(this.c);
        this.n.addView(localFrameLayout, -1, -1);
        View localView = b(paramInt);
        int i1 = s.b(this.c, 10.0F);
        localFrameLayout.setPadding(i1, i1, i1, i1);
        if (localView == null)
            throw new IllegalArgumentException("@APayFloat: Float's content can't be null.");
        FrameLayout.LayoutParams localLayoutParams = new FrameLayout.LayoutParams(-1, -2);
        localLayoutParams.gravity = 17;
        LinearLayout localLinearLayout = new LinearLayout(this.c);
        localLinearLayout.setOrientation(1);
        this.d.a(localLinearLayout, -1073741767);
        localLinearLayout.setPadding(localLinearLayout.getPaddingLeft(), localLinearLayout.getPaddingTop() + 2,
                localLinearLayout.getPaddingRight(), localLinearLayout.getPaddingBottom());
        localFrameLayout.addView(localLinearLayout, localLayoutParams);
        int i2 = i1 * 3 / 2;
        this.o = new LinearLayout(this.c);
        this.o.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
        this.o.setPadding(i2, i1, i2, i1);
        this.o.setBackgroundColor(-394759);
        this.k = new ImageView(this.c);
        this.k.setImageDrawable(this.d.a(1073741894));
        this.k.setLayoutParams(new LinearLayout.LayoutParams(s.b(this.c, 119.0F), s.b(this.c, 20.0F)));
        this.o.addView(this.k);
        localLinearLayout.addView(this.o);
        this.j = new View(this.c);
        this.j.setBackgroundColor(-1447447);
        localLinearLayout.addView(this.j, -1, 1);
        ScrollView localScrollView = new ScrollView(this.c);
        localScrollView.setPadding(i2, i1 / 2, i2, i1 / 2);
        localScrollView.setScrollBarStyle(33554432);
        localScrollView.addView(localView);
        localLinearLayout.addView(localScrollView, -1, -2);
        localLayoutParams = new FrameLayout.LayoutParams(s.b(this.c, 32.0F), s.b(this.c, 32.0F));
        localLayoutParams.gravity = 53;
        this.m = new ImageView(this.c);
        this.d.a(this.m, 1073741883, 1073741884, 0);
        this.m.setPadding(i1 * 3 / 2, i1, i1, i1 * 3 / 2);
        this.m.setLayoutParams(localLayoutParams);
        this.n.addView(this.m);
        this.m.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                QHStatDo.event("360sdk_pay_dialog_close_button_click", null);
                a.this.a();
            }
        });
    }

    public void a(boolean paramBoolean) {
        if (this.o != null)
            this.o.setVisibility((!(paramBoolean)) ? 8 : 0);
        if (this.j == null)
            return;
        this.j.setVisibility((!(paramBoolean)) ? 8 : 0);
    }

    public void b(boolean paramBoolean) {
        if (this.m == null)
            return;
        this.m.setVisibility((paramBoolean) ? 0 : 8);
    }

    public void a(com.qihoo.gamecenter.sdk.pay.k.a parama) {
        this.e = parama;
    }

    protected abstract View b(int paramInt);

    public void a(int paramInt1, int paramInt2) {
        a();
        if (this.n == null)
            throw new IllegalArgumentException("@APayFloat: initialize must be called before!");
        ViewParent localViewParent = this.n.getParent();
        if (localViewParent instanceof ViewGroup)
            ((ViewGroup) localViewParent).removeView(this.n);
        this.l = new c(this.c);
        this.l.d(this.a);
        this.l.a(false);
        this.l.b(0);
        this.l.a(this.n, paramInt1, paramInt2);
        this.l.setOnCancelListener(this.q);
        this.l.setOnDismissListener(this.r);
        this.l.setCancelable(this.g);
        this.l.a(0, 0, 0, 0);
        this.l.setCanceledOnTouchOutside(this.h);
        this.l.show();
    }

    public final boolean a() {
        return c(65285);
    }

    public void a(long paramLong) {
        this.n.postDelayed(new Runnable() {
            public void run() {
                a.this.c(65285);
            }
        }, paramLong);
    }

    public final boolean c(int paramInt) {
        this.i = paramInt;
        if ((this.l != null) && (this.l.isShowing())) {
            this.l.dismiss();
            return true;
        }
        return false;
    }

    public final void c(boolean paramBoolean) {
        this.p = paramBoolean;
        if ((this.l == null) || (!(this.l.isShowing())))
            return;
        this.l.dismiss();
    }

    public final void d(boolean paramBoolean) {
        this.g = paramBoolean;
        if (this.l == null)
            return;
        this.l.setCancelable(this.g);
    }

    public final void e(boolean paramBoolean) {
        this.f = paramBoolean;
    }

    public final void f(boolean paramBoolean) {
        this.h = paramBoolean;
        if (this.l == null)
            return;
        this.l.setCanceledOnTouchOutside(this.h);
    }
}